package com.example.studyapp

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import android.widget.Button
import android.widget.EditText
import android.widget.Toast

class change_password_1 : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_change_password_1)
        val change_password_save: Button =this.findViewById(R.id.change_password_save)
        val change_username_old: EditText =this.findViewById(R.id.change_password_old)
        val change_username_new:EditText=this.findViewById(R.id.change_password_new)
        val change_username_new1:EditText=this.findViewById(R.id.change_password_new1)
        change_password_save.setOnClickListener { v->
            if(change_username_old.text.length<=0){
                return@setOnClickListener
            }
            if(change_username_new.text.length< define_password_min_length){
                Toast.makeText(this, "密码应大于4个字符", Toast.LENGTH_SHORT)
                    .show()
                return@setOnClickListener
            }
            if(change_username_new.text!=change_username_new1.text){
                Toast.makeText(this, "密码不匹配", Toast.LENGTH_SHORT)
                    .show()
                return@setOnClickListener
            }
            //从服务器获取当前用户密码，比较是否相同，发送{"dataclass":"password","username":"用户名"}

            //然后退出当前界面
            Toast.makeText(this, "密码修改成功", Toast.LENGTH_SHORT)
                .show()
            this.finish()
        }
    }
}